<?php

require( realpath('..') . '/includes/admin.php' );
$dora->lib('message');

if( action('login') ) {
	$dora->database();
	
	$name = $_POST['name'];	
	$passwd = $_POST['passwd'];
	$admin = $dora->db->get_result("select * from admin where name='$name'");	
	if( $admin ) {
		if( $admin['passwd'] == $passwd ) {
			$_SESSION['id'] = $admin['id'];
			$_SESSION['name'] = $admin['name'];

			header("Location: index.php");
			return;
		}
	}
	
	$dora->message->set('用户名或密码错误');
	$dora->view('login');
}
else {
	$dora->view('login');
}

?>